package com.zkzx.common.constants;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author young Email:yanghui@zkraising.com
 * @description 省份简称
 * @company 北京中科智兴物联科技有限公司 @版权所有
 * @since 2021年05月10日 14时59分
 */
@Getter
@AllArgsConstructor
public enum ProvinceEnum {

    // name 生成规则  省份首字母_简称首字母
    BJ_J("","京","北京市"),
    TJ_J("","津","天津市"),
    SH_H("","沪","上海市"),
    CQ_Y("","渝","重庆市"),
    NX_N("","宁","宁夏回族自治区"),
    XJ_X("","新","疆维吾尔自治区"),
    XZ_Z("","藏","西藏自治区"),
    GX_G("","桂","广西壮族自治区"),
    NMG_M("","蒙","内蒙古自治区"),
    LN_L("","辽","辽宁省"),
    JL_J("","吉","吉林省"),
    HLJ_H("","黑","黑龙江省"),
    HB_J("","冀","河北省"),
    SX_J("","晋","山西省"),
    JS_S("","苏","江苏省"),
    ZJ_Z("","浙","浙江省"),
    AH_Y("","皖","安徽省"),
    FJ_M("","闽","福建省"),
    JX_G("","赣","江西省"),
    SD_L("","鲁","山东省"),
    HN_Y("","豫","河南省"),
    HB_E("","鄂","湖北省"),
    HN_X("","湘","湖南省"),
    HN_Q("","琼","海南省"),
    SC_S("","川","四川省"),
    GZ_G("","贵","贵州省"),
    YN_Y("","云","云南省"),
    SX_S("","陕","陕西省"),
    GS_G("","甘","甘肃省"),
    QH_Q("","青","青海省"),
    TW_T("","台","台湾"),
    AM_A("","澳","澳门"),
    XG_X("","香","香港");

    private String code;

    private String value;

    private String province;

    /**
     * 根据省份简称获取枚举信息
     * @param value
     * @return
     */
    public static ProvinceEnum getByValue(String value){
        ProvinceEnum[] values = ProvinceEnum.values();
        Optional<ProvinceEnum> first = Arrays.stream(values).filter(v -> v.value.equals(value)).findFirst();
        if(first.isPresent()){
            return first.get();
        }
        return null;
    }
}
